package main

import (
	"encoding/json"
	"fmt"
)

type person struct {
	Name string `json:"name"` //Name小写不会反序列化
	Age  string `json:"age"`
}

func main() {
	map1 := map[string]string{"name": "yj", "class": "class1"}
	//序列化
	str, _ := json.Marshal(map1)
	fmt.Println(string(str))

	strU := []byte(`{"name":"d","age":"12"}`)
	var p = person{}
	//反序列化
	json.Unmarshal(strU, &p)
	fmt.Println(p)
}
